package chapter7_取消关闭.未捕获异常处理;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 日志打印
 *
 * 备注：executor对execute提交的任务才能将它抛出的异常交给未捕获异常处理器，通过submit提交的任务，无论时抛出的未检查异常
 * 还是已检查异常，都将被认为时任务返回状态的一部分。submit提交的任务如果抛了异常是封装到Future.get封装在ExecutionException中重新抛出
 */
public class UncaughtExceptionHandlerSnippet implements Thread.UncaughtExceptionHandler {

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        Logger logger = Logger.getAnonymousLogger();
        logger.log(Level.SEVERE, "Thread terminated with exception: " + t.getName(), e);
    }
}
